home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 109_01.zip / PNUM.C < prev    next >
Text File  |  1993-06-26  |  640b  |  33 lines

  1.  
  2. /*
  3.     This command prints out a given file with line
  4.     numbers. Usage:
  5.  
  6.         A>pnum filename <cr>
  7.  
  8.     written by Leor Zolman
  9.            Jan, 1980
  10.     modified March 1980 to make all printing take place in one
  11.     (short)    statement. Try THAT with BASIC!
  12. */
  13.  
  14. main(argc,argv)
  15. char **argv;
  16. {
  17.     int fd, lnum;
  18.     char ibuf[134], linebuf[132];
  19.  
  20.     if (argc != 2) {
  21.         printf("Usage: pnum filename\n");
  22.         exit();
  23.     }
  24.     if ((fd = fopen(argv[1], ibuf)) == -1) {
  25.         printf("cannot open: %s\n",argv[1]);
  26.         exit();
  27.     }
  28.     lnum = 1;
  29.     while (fgets(linebuf, ibuf))
  30.          printf("%3d: %s",lnum++,linebuf);
  31. }
  32.  
  33.